using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;

namespace FU.Capstones.IMS.Web.Common.InventoryServiceProxy.DataContracts
{
    [KnownType(typeof(MaterialCriteria))]
    [DataContract(Namespace = WebConstants.ServiceNamespace)]
    public class Material : BindingModelBase<Material>
    {
        public Material()
        {
            AddAllAttributeValidators();
        }

        private int materialID;
        [DataMember]
        [Key]
        public int MaterialID
        {
            get { return materialID; }
            set
            {
                if(!Equals(materialID,value))
                {
                    materialID = value;
                    RaisePropertyChanged(() => MaterialID);
                }
            }
        }

        private int warehouseID;
        [DataMember] 
        public int WarehouseID
        {
            get { return warehouseID; }
            set
            {
                if (!Equals(warehouseID, value))
                {
                    warehouseID = value;
                    RaisePropertyChanged(() => WarehouseID);
                }
            }
        }

        private int supplierID;
        [DataMember]
        [Key]
        public int SupplierID
        {
            get { return supplierID; }
            set
            {
                if (!Equals(supplierID, value))
                {
                    supplierID = value;
                    RaisePropertyChanged(() => SupplierID);
                }
            }
        }
        private string materialCode;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Mã vật liệu không đưọc bỏ trống.")]
        [StringLength(10, ErrorMessage = "Mã vật liệu không dài quá 10 kí tự.")]
        public string MaterialCode
        {
            get { return materialCode; }
            set
            {
                if (!Equals(materialCode, value))
                {
                    materialCode = value;
                    RaisePropertyChanged(() => MaterialCode);
                }
            }
        }

        public string MaterialCodeSearch
        {
            get { return materialCode; }
            set
            {
                if (!Equals(materialCode, value))
                {
                    materialCode = value;
                    RaisePropertyChanged(() => MaterialCodeSearch);
                }
            }
        }

        private string materialName;
        [DataMember]
        [Required(AllowEmptyStrings = false, ErrorMessage = "Tên vật liệu không đưọc bỏ trống.")]
        [StringLength(30, ErrorMessage = "Tên vật liệu không dài quá 30 kí tự.")]
        public string MaterialName
        {
            get { return materialName; }
            set
            {
                if(!ReferenceEquals(materialName,value))
                {
                    materialName = value;
                    RaisePropertyChanged(() => MaterialName);
                }
            }
        }

        public string MaterialNameSearch
        {
            get { return materialName; }
            set
            {
                if (!ReferenceEquals(materialName, value))
                {
                    materialName = value;
                    RaisePropertyChanged(() => MaterialNameSearch);
                }
            }
        }

        private string description;
        [DataMember]
        public string Description
        {
            get { return description; }
            set
            {
                if(!ReferenceEquals(description,value))
                {
                    description = value;
                    RaisePropertyChanged(() => Description);
                }
            }
        }

        private long quantity;
        [DataMember]
        public long Quantity
        {
            get { return quantity; }
            set
            {
                if(!Equals(quantity,value))
                {
                    quantity = value;
                    RaisePropertyChanged(() => Quantity);
                }
            }
        }

        private double pricePerUnit;
        [DataMember]
        public double PricePerUnit
        {
            get { return pricePerUnit; }
            set
            {
                if(!Equals(pricePerUnit,value))
                {
                    pricePerUnit = value;
                    RaisePropertyChanged(() => PricePerUnit);
                }
            }
        }

        private bool isDelete;
        [DataMember]
        public bool IsDelete
        {
            get { return isDelete; }
            set
            {
                if (!Equals(isDelete, value))
                {
                    isDelete = value;
                    RaisePropertyChanged(() => IsDelete);
                }
            }
        }

        private Warehouse warehouse;
        [DataMember]
        public Warehouse Warehouse
        {
            get { return warehouse; }
            set
            {
                if (!ReferenceEquals(warehouse, value))
                {
                    warehouse = value;
                    RaisePropertyChanged(() => Warehouse);
                }
            }
        }

        private bool isSelected;
        [DataMember]
        public bool IsSelected
        {
            get { return isSelected; }
            set
            {
                if (!Equals(isSelected, value))
                {
                    isSelected = value;
                    RaisePropertyChanged(() => IsSelected);
                }
            }
        }

    }
}
